unit Functions;

interface

type
 TFunction = class
 private
  a: real;
  b: real;
 public
  constructor Create(X1, Y1, X2, Y2: integer);
  function GetValue(X: integer): integer;
 end;

implementation

function TFunction.GetValue(X: integer): Integer;
begin
 Result := Trunc(a*X + b);
end;

constructor TFunction.Create(X1, Y1, X2, Y2: integer);
begin
 a := (Y1 - Y2)/(X1 - X2);
 b := (X2 * Y2 - X1 * Y2)/(X2 - X1);
end;

end.
